<template>
	<view style="padding: 10rpx;">
		 <view>
		 		<text style="font-weight: bold;">{{blog.title}}</text>
		 </view>
		 <text style="display: inline-block;color: #CA0C16;background-color: #f0f9eb">{{blog.type}}</text>
		  <text style="display: inline-block;color: #858585;margin-left: 3px">作者{{blog.authorName}}</text>
		         <text class="el-icon-thumb" style="display: inline-block;color: #858585;margin-left: 3px">&nbsp;点赞数{{blog.praiseQuantity}}</text>
		         <text class="el-icon-reading" style="display: inline-block;color: #858585;">&nbsp;浏览数{{blog.browseQuantity}}</text>
		 <view>
		 <view v-if="blog.label1!=undefined&&blog.label1!=''">
			 <image :src="blog.label1" style="width: 100%;"></image>
		 </view>
		 
		 
		
		 
			<text v-html="blog.content"></text>
		</view>
		
		<view class="btn" v-if="blog.onShelf==0||blog.onShelf=='0'||blog.onShelf==undefined">
			<button type="primary" @click="recommend">上架</button>
		</view>
		
		<view v-else>
			<button class="btn" type="default" @click="recommendNot">下架</button>
		</view>
	</view>
	
</template>

<script>
	import http from '../../../common/request.js'
	export default {
		 onLoad(options){
			   this.id=options.id
			   this.getVO(options.id)
		    },
		data() {
			return {
				id:undefined,
				blog:{}
			}
		},
		methods: {
			async getVO(id){
				const res = await http.request({
					url: '/blog/'+id,
					data:{}
				})
				let obj=res.data
				console.log(obj)
				this.blog = obj.data
			},
			
			async recommend(){
				const res = await http.request({
					url: '/blog/recommend?id='+this.id,
					method:'post',
					data:{}
				})
				let obj=res.data
				if(obj.data){
					this.getVO(this.id)
				}
				console.log(obj)
			},
			
			async recommendNot(){
				const res = await http.request({
					url: '/blog/recommend_not?id='+this.id,
					method:'post',
					data:{}
				})
				let obj=res.data
				if(obj.data){
					this.getVO(this.id)
				}
				console.log(obj)
			}
			
		}
	}
</script>

<style>
 .btn{
	 margin-top: 15rpx;
 }
</style>
